#include "util/Image.h"

namespace util {

Image::Image()
  : width_(0)
  , height_(0)
{
}

Image::Image(std::size_t width, std::size_t height)
  : width_(width)
  , height_(height)
  , values_(width*height, 0)
{
}

Image::Image(std::size_t width, std::size_t height, const std::vector<int>& values)
  : width_(width)
  , height_(height)
  , values_(values)
{
  std::size_t dim = width_*height_;
  if (values_.size() > dim)
    values_.resize(dim);
}

int Image::getValue(std::size_t x, std::size_t y) const
{
  return values_[x + y*width_];
}

void Image::setValue(std::size_t x, std::size_t y, int value)
{
  values_[x + y*width_] = value;
}

} // namespace util
